
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 02/17/2015 12:50:09
-- Generated from EDMX file: D:\Documents\Visual Studio 2013\Projects\Big Data\Big Data\Big Data\Entities\Offres_facteurs.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [Offres_facteurs];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PaysEmploi]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EmploiSet] DROP CONSTRAINT [FK_PaysEmploi];
GO
IF OBJECT_ID(N'[dbo].[FK_DateEmploi]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EmploiSet] DROP CONSTRAINT [FK_DateEmploi];
GO
IF OBJECT_ID(N'[dbo].[FK_PaysPopulation_Active]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Population_ActiveSet] DROP CONSTRAINT [FK_PaysPopulation_Active];
GO
IF OBJECT_ID(N'[dbo].[FK_DatePopulation_Active]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Population_ActiveSet] DROP CONSTRAINT [FK_DatePopulation_Active];
GO
IF OBJECT_ID(N'[dbo].[FK_PaysMain_Oeuvre]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Main_OeuvreSet] DROP CONSTRAINT [FK_PaysMain_Oeuvre];
GO
IF OBJECT_ID(N'[dbo].[FK_DateMain_Oeuvre]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Main_OeuvreSet] DROP CONSTRAINT [FK_DateMain_Oeuvre];
GO
IF OBJECT_ID(N'[dbo].[FK_PaysChomage]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ChomageSet] DROP CONSTRAINT [FK_PaysChomage];
GO
IF OBJECT_ID(N'[dbo].[FK_DateChomage]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ChomageSet] DROP CONSTRAINT [FK_DateChomage];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[PaysSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PaysSet];
GO
IF OBJECT_ID(N'[dbo].[DateSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DateSet];
GO
IF OBJECT_ID(N'[dbo].[EmploiSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EmploiSet];
GO
IF OBJECT_ID(N'[dbo].[Population_ActiveSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Population_ActiveSet];
GO
IF OBJECT_ID(N'[dbo].[ChomageSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ChomageSet];
GO
IF OBJECT_ID(N'[dbo].[Main_OeuvreSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Main_OeuvreSet];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'PaysSet'
CREATE TABLE [dbo].[PaysSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'DateSet'
CREATE TABLE [dbo].[DateSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Année] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'EmploiSet'
CREATE TABLE [dbo].[EmploiSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Valeurs] nvarchar(max)  NOT NULL,
    [PaysId] int  NOT NULL,
    [DateId] int  NOT NULL
);
GO

-- Creating table 'Population_ActiveSet'
CREATE TABLE [dbo].[Population_ActiveSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Valeurs] nvarchar(max)  NOT NULL,
    [PaysId] int  NOT NULL,
    [DateId] int  NOT NULL
);
GO

-- Creating table 'ChomageSet'
CREATE TABLE [dbo].[ChomageSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Valeurs] nvarchar(max)  NOT NULL,
    [PaysId] int  NOT NULL,
    [DateId] int  NOT NULL
);
GO

-- Creating table 'Main_OeuvreSet'
CREATE TABLE [dbo].[Main_OeuvreSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Valeurs] nvarchar(max)  NOT NULL,
    [PaysId] int  NOT NULL,
    [DateId] int  NOT NULL
);
GO

-- Creating table 'DepenseSanteChargePatientSet'
CREATE TABLE [dbo].[DepenseSanteChargePatientSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Valeurs] nvarchar(max)  NOT NULL,
    [DateSanteId] int  NOT NULL,
    [PaysSanteId] int  NOT NULL
);
GO

-- Creating table 'PaysSanteSet'
CREATE TABLE [dbo].[PaysSanteSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Pays] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'DateSanteSet'
CREATE TABLE [dbo].[DateSanteSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Date] nvarchar(max)  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'PaysSet'
ALTER TABLE [dbo].[PaysSet]
ADD CONSTRAINT [PK_PaysSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'DateSet'
ALTER TABLE [dbo].[DateSet]
ADD CONSTRAINT [PK_DateSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'EmploiSet'
ALTER TABLE [dbo].[EmploiSet]
ADD CONSTRAINT [PK_EmploiSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Population_ActiveSet'
ALTER TABLE [dbo].[Population_ActiveSet]
ADD CONSTRAINT [PK_Population_ActiveSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ChomageSet'
ALTER TABLE [dbo].[ChomageSet]
ADD CONSTRAINT [PK_ChomageSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Main_OeuvreSet'
ALTER TABLE [dbo].[Main_OeuvreSet]
ADD CONSTRAINT [PK_Main_OeuvreSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'DepenseSanteChargePatientSet'
ALTER TABLE [dbo].[DepenseSanteChargePatientSet]
ADD CONSTRAINT [PK_DepenseSanteChargePatientSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PaysSanteSet'
ALTER TABLE [dbo].[PaysSanteSet]
ADD CONSTRAINT [PK_PaysSanteSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'DateSanteSet'
ALTER TABLE [dbo].[DateSanteSet]
ADD CONSTRAINT [PK_DateSanteSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [PaysId] in table 'EmploiSet'
ALTER TABLE [dbo].[EmploiSet]
ADD CONSTRAINT [FK_PaysEmploi]
    FOREIGN KEY ([PaysId])
    REFERENCES [dbo].[PaysSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_PaysEmploi'
CREATE INDEX [IX_FK_PaysEmploi]
ON [dbo].[EmploiSet]
    ([PaysId]);
GO

-- Creating foreign key on [DateId] in table 'EmploiSet'
ALTER TABLE [dbo].[EmploiSet]
ADD CONSTRAINT [FK_DateEmploi]
    FOREIGN KEY ([DateId])
    REFERENCES [dbo].[DateSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_DateEmploi'
CREATE INDEX [IX_FK_DateEmploi]
ON [dbo].[EmploiSet]
    ([DateId]);
GO

-- Creating foreign key on [PaysId] in table 'Population_ActiveSet'
ALTER TABLE [dbo].[Population_ActiveSet]
ADD CONSTRAINT [FK_PaysPopulation_Active]
    FOREIGN KEY ([PaysId])
    REFERENCES [dbo].[PaysSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_PaysPopulation_Active'
CREATE INDEX [IX_FK_PaysPopulation_Active]
ON [dbo].[Population_ActiveSet]
    ([PaysId]);
GO

-- Creating foreign key on [DateId] in table 'Population_ActiveSet'
ALTER TABLE [dbo].[Population_ActiveSet]
ADD CONSTRAINT [FK_DatePopulation_Active]
    FOREIGN KEY ([DateId])
    REFERENCES [dbo].[DateSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_DatePopulation_Active'
CREATE INDEX [IX_FK_DatePopulation_Active]
ON [dbo].[Population_ActiveSet]
    ([DateId]);
GO

-- Creating foreign key on [PaysId] in table 'Main_OeuvreSet'
ALTER TABLE [dbo].[Main_OeuvreSet]
ADD CONSTRAINT [FK_PaysMain_Oeuvre]
    FOREIGN KEY ([PaysId])
    REFERENCES [dbo].[PaysSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_PaysMain_Oeuvre'
CREATE INDEX [IX_FK_PaysMain_Oeuvre]
ON [dbo].[Main_OeuvreSet]
    ([PaysId]);
GO

-- Creating foreign key on [DateId] in table 'Main_OeuvreSet'
ALTER TABLE [dbo].[Main_OeuvreSet]
ADD CONSTRAINT [FK_DateMain_Oeuvre]
    FOREIGN KEY ([DateId])
    REFERENCES [dbo].[DateSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_DateMain_Oeuvre'
CREATE INDEX [IX_FK_DateMain_Oeuvre]
ON [dbo].[Main_OeuvreSet]
    ([DateId]);
GO

-- Creating foreign key on [PaysId] in table 'ChomageSet'
ALTER TABLE [dbo].[ChomageSet]
ADD CONSTRAINT [FK_PaysChomage]
    FOREIGN KEY ([PaysId])
    REFERENCES [dbo].[PaysSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_PaysChomage'
CREATE INDEX [IX_FK_PaysChomage]
ON [dbo].[ChomageSet]
    ([PaysId]);
GO

-- Creating foreign key on [DateId] in table 'ChomageSet'
ALTER TABLE [dbo].[ChomageSet]
ADD CONSTRAINT [FK_DateChomage]
    FOREIGN KEY ([DateId])
    REFERENCES [dbo].[DateSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_DateChomage'
CREATE INDEX [IX_FK_DateChomage]
ON [dbo].[ChomageSet]
    ([DateId]);
GO

-- Creating foreign key on [DateSanteId] in table 'DepenseSanteChargePatientSet'
ALTER TABLE [dbo].[DepenseSanteChargePatientSet]
ADD CONSTRAINT [FK_DateSanteDepenseSanteChargePatient]
    FOREIGN KEY ([DateSanteId])
    REFERENCES [dbo].[DateSanteSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_DateSanteDepenseSanteChargePatient'
CREATE INDEX [IX_FK_DateSanteDepenseSanteChargePatient]
ON [dbo].[DepenseSanteChargePatientSet]
    ([DateSanteId]);
GO

-- Creating foreign key on [PaysSanteId] in table 'DepenseSanteChargePatientSet'
ALTER TABLE [dbo].[DepenseSanteChargePatientSet]
ADD CONSTRAINT [FK_PaysSanteDepenseSanteChargePatient]
    FOREIGN KEY ([PaysSanteId])
    REFERENCES [dbo].[PaysSanteSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_PaysSanteDepenseSanteChargePatient'
CREATE INDEX [IX_FK_PaysSanteDepenseSanteChargePatient]
ON [dbo].[DepenseSanteChargePatientSet]
    ([PaysSanteId]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------